package com.itheima.springbootwebtlias.mapper;

import com.itheima.springbootwebtlias.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 部门持久层接口：处理部门相关的持久层操作
 */
@Mapper
public interface DeptMapper {
//    //定义查询部门列表
//    @Results( 手动映射
//            {
//                    @Result(property = "createTime",column = "create_time"),
//                    @Result(property = "updateTime",column = "update_time")
//            }
//    )
    @Select("select * from dept")
    List<Dept> selectAll();

    //删除部门
    @Delete("delete from dept where id=#{id};")
    void removeById(Integer id);

    //添加部门
    @Insert("insert into dept (id, name, create_time, update_time) values (null,#{name},#{createTime},#{updateTime});")
    void saveDept(Dept dept);

    //根据id查询部门
    @Select("select * from dept where id = #{id};")
    Dept selectById(int id);

    //修改部门
    @Update("update dept set name = #{name}, update_time = #{updateTime} where id=#{id};")
    void update(Dept dept);
}
